package yf.mall.enums;

import lombok.Getter;

import java.util.Arrays;

@Getter
public enum LevelAuthEnum {
    SANPING(0,"三品"),

    XIUXINGZHE(1,"修行者"),


    QAUNSHOU(2,"圈瘦");

    int index;
    String value;

    public static String[] names() {
        return Arrays.stream(LevelAuthEnum.values()).map(m -> m.getValue()).toArray(String[]::new);
    }

    LevelAuthEnum(int index, String value) {
        this.index = index;
        this.value = value;
    }

    public static String indexOf(int idx) {
        return LevelAuthEnum.values()[idx].getValue();
    }

    public static int indexOf(String name){
        for (int i = 0; i < names().length; i++) {
            if(names()[i].equals(name)){
                return i;
            }
        }
        throw new RuntimeException("enum不存在");
    }

    public static void main(String[] args) {
        System.out.println(LevelAuthEnum.indexOf("圈瘦"));
    }

}
